package com.ts.oss.service.Impl;

import com.ts.oss.service.SmsService;
import com.ts.oss.util.SmsUtils;
import com.zhenzi.sms.ZhenziSmsClient;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class SmsServiceImpl implements SmsService {
    @Override
    public void sendMessage(String mobile, String fourBitRandom) {
        ZhenziSmsClient client=new ZhenziSmsClient(SmsUtils.API_URL,SmsUtils.APP_ID,SmsUtils.APP_SECRET);
        HashMap<String, Object> map = new HashMap<>();
        map.put("templateId","12812");
        map.put("number",mobile);

        String[] templateParams=new String[2];
        templateParams[0]=fourBitRandom;
        templateParams[1]="3";
        map.put("templateParams",templateParams);
        try {
            String result = client.send(map);
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
